<template>
  <div></div>
</template>

<script>
import { getToken } from '@/utils/auth'
export default {
  data() {
    return {}
  },
  mounted() {
    this.nextPage();
  },
  computed:{
    wxredirect_uri(){
      return encodeURIComponent(this.$store.state.settings.wxredirect_uri)
    },
    wxappid(){
      return this.$store.state.settings.wxappid
    },
    wxagentid(){
      return this.$store.state.settings.wxagentid
    },
    wxpage(){
      let url = 'https://open.weixin.qq.com/connect/oauth2/authorize?'
      url += 'appid=' + this.wxappid
      url += '&redirect_uri=' + this.wxredirect_uri
      url += '&response_type=code&scope=snsapi_privateinfo&state=STATE'
      url += "&agentid=" + this.wxagentid + "#wechat_redirect"
      return url;
    }
  },
  methods: {
    nextPage(){
      if (getToken()) {
        this.$router.push("/")
      }else{
        const wxpage = this.wxpage;
        this.$store.dispatch('user/logout').then(() => {
          window.location.href = wxpage
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
